<%@page import="java.util.Enumeration"%>
<%@page import="java.io.BufferedReader"%>
<%@page import="com.alibaba.fastjson.JSONObject"%>
<%@page import="com.alibaba.fastjson.JSON"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%
	JSONObject json = new JSONObject();
	json.put("headerParams",getHeaderString(request));
	json.put("formParams",getFormString(request));
	json.put("bodyParams",getBodyString(request));
	out.print(json.toJSONString());
%>

<%!
public JSONObject getHeaderString(HttpServletRequest request){
	JSONObject o = new JSONObject();
	Enumeration<String> em = request.getHeaderNames();
	 while (em.hasMoreElements()) {
	    String name =  em.nextElement();
	    String value = request.getHeader(name);
	    o.put(name,value);
	}
	return o;
}

public JSONObject getFormString(HttpServletRequest request){
	JSONObject o = new JSONObject();
	Enumeration<String> em = request.getParameterNames();
	 while (em.hasMoreElements()) {
	    String name =  em.nextElement();
	    String value = request.getParameter(name);
	    o.put(name,value);
	}
	return o;
}

public String getBodyString(HttpServletRequest request) {
	String inputLine;
	String str = "";
	try {
		BufferedReader br = request.getReader();
		while ((inputLine = br.readLine()) != null) {
			str += inputLine;
		}
		br.close();
	} catch (Exception e) {
		System.out.println("IOException: " + e);
	}
	return str;
}
%>